<form id="usrform" role="form" action="<?php echo base_url().'gasstation/activity/save_newuser_coupon';?>" method="post" onsubmit="return submit_form(this);">

	<div class="modal-dialog" style="width: 700px">
		<div class="modal-content">
			<div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h3>拉新红包</h3><br/>
			  <span id="yh" name="yh"></span>
		</div>
			<div class="modal-body">
            <table width="100%"  border="0" cellpadding="5px" style="border-collapse:separate; border-spacing:0px 20px;">
              <tr>
                <th scope="row">活动名称：</th>
                <td><input type="text" name="title" value="<?php echo !empty($info['title'])?$info['title']:''?>" style=" padding:5px;" /></td>
              </tr>
           	  
              <tr>
                <th scope="row">活动时间：</th>
                <td><input type="text" name="start_time" value="<?php echo !empty($info['start_time'])?$info['start_time']:''?>" style=" padding:5px;" id="start_time" placeholder="年-月-日 时:分:秒"/>到<input type="text" name="end_time" id="end_time" value="<?php echo !empty($info['end_time'])?$info['end_time']:''?>" style=" padding:5px;" placeholder="年-月-日 时:分:秒"/></td>
              </tr>
              
              <tr>
                <th scope="row">面向对象：</th>
                <td><input type="radio" name="car_type" value="-1"  <?php if(!isset($info['car_type'])||$info['car_type']==-1):?> checked="checked"<?php endif; ?> />所有对象 
                <input type="radio" name="car_type" value="0" <?php if(isset($info['car_type'])&&$info['car_type']==0):?> checked="checked"<?php endif; ?>/>私家车 
                <input type="radio" name="car_type" name="car_type" value="1" <?php if(isset($info['car_type'])&&$info['car_type']==1):?> checked="checked"<?php endif; ?>/>网约车 </td>
              </tr>
              
              <tr>
                <th scope="row">参与油品：</th>
                <td><input type="radio" name="gm_id" value="0"  <?php if(empty($info['gm_id'])):?> checked="checked"<?php endif; ?> />所有油品
                
                <?php foreach($list as $v):?>
                <input type="radio" name="gm_id" value="<?php echo $v['gm_id']?>" <?php if(!empty($info['gm_id'])&&$v['gm_id']==$info['gm_id']):?> checked="checked"<?php endif; ?>/><?php echo $v['glmodel_name']?>
                <?php endforeach;?>
                
                </td>
              </tr>
              
              <tr>
                <th scope="row">派面金额：</th>
                <td><input type="text" style="width:50px;" name="coupon_price" value="<?php echo !empty($info['coupon_price'])?$info['coupon_price']:''?>"/>元</td>
              </tr>
             
              
              <tr>
                <th scope="row">使用条件：</th>
                <td>
                <input type="radio" name="use_price_type" value="0" <?php if(!empty($info['use_price'])&&$info['use_price']==0.00):?> checked="checked"<?php endif; ?>/>无门槛 
                <input type="radio" name="use_price_type" value="1" <?php if(!empty($info['use_price'])&&$info['use_price']!=0.00):?> checked="checked"<?php endif; ?> />满<input type="text" style="width:50px;"  name="use_price" value="<?php echo !empty($info['use_price'])?$info['use_price']:''?>"/>元可用</td>
              </tr>
             
              <tr>
                <th scope="row">有效期：</th>
                <td>自领券之日起<input  type="text" style="width:50px;" name="days" value="<?php echo !empty($info['coupon_days'])?$info['coupon_days']:''?>"/>天有效</td>
              </tr>
              
              
              <input type="hidden" name="id"  value="<?php echo !empty($info['id'])?$info['id']:0?>" />
            </table>
            
            </div>
			<div class="modal-footer">
			<button id="btnSubmit" class="btn btn-get" type="submit" style="background: #F18101;color:#FFFFFF;position:relative;left:-45%;padding: 5px 20px;">确定</button>
			</div>
		</div>
	</div>
</form>

<script>

function submit_form(t){
	
	$('button[type="submit"]').attr('disabled',true);
	$.ajax({
	   type: "POST",
	   url: $(t).attr('action'),
	   data: $(t).serialize(),
	   dataType:"json",
	   success: function(rs){
		 if(rs.error==1){
			 	alert(rs.msg);
				$('button[type="submit"]').attr('disabled',false);
			 }else{
				window.location.reload()
			}
	   }
	});
	
	return false;
	
	}

layui.use(['laydate'], function(){

  	laydate = layui.laydate;

  //时间选择器
  laydate.render({
    elem: '#start_time',
	type: 'datetime'
  });
	
  //时间选择器
  laydate.render({
    elem: '#end_time',
	type: 'datetime'
  });


});
</script>

